import DS from 'ember-data';
import BaseModel from './base-model';

export default BaseModel.extend({
  dateService: Ember.inject.service("date-service"),
  billStatus:DS.belongsTo('dicttype'),//提交状态  未提交 已提交 审核通过 审核未通过
  operateUser:DS.belongsTo('user'),// 审核人
  auditTime:DS.attr('number'),// 审核时间
  createUser:DS.belongsTo('user'),//提交人
  billTime:DS.attr('number'),// 账单提交时间
  createTime:DS.attr('number'),// 记录生成时间
  totalAmount: DS.attr('number'),// 账单总金额（最后填写的金额，可修改）
  accountAmount: DS.attr('number'),// 账户结算金额
  depositAmount: DS.attr('number'),// 保证金退费金额
  billType:DS.belongsTo('dicttype'),// 退费/扣费
  customer:DS.belongsTo('customer'),//账单客户
  lastUpdateDateTime:DS.attr('number'),//更新时间
  createDateTime:DS.attr('number'),//创建时间
  lastUpdateUser:DS.belongsTo('user'),//更新操作者userid
  remark: DS.attr('string'),//备注
  createDateTimeStr:Ember.computed("createDateTime", function() {
      var createDateTime = this.get("createDateTime");
      return createDateTime?this.get("dateService").formatDate(createDateTime, "yyyy-MM-dd"):'无';
  }),
  billTimeStr:Ember.computed("billTime", function() {
      var billTime = this.get("billTime");
      return billTime?this.get("dateService").formatDate(billTime, "yyyy-MM-dd"):'无';
  }),
  auditTimeStr:Ember.computed("auditTime", function() {
      var auditTime = this.get("auditTime");
      return auditTime?this.get("dateService").formatDate(auditTime, "yyyy-MM-dd"):'无';
  }),
  submitFlag:Ember.computed('billStatus',function(){
    let status = this.get('billStatus');
    if(status.get('typecode')=='billStatus0'){
      return true;
    }else{
      return false;
    }
  }),
});
